package com.wy.io.OutputStream;

import java.io.*;

/**
 * @author 美女
 * @date 2022/05/13 15:37
 **/
public class WriteText {
    public static void main(String[] args) throws IOException {
        try(OutputStream os=new FileOutputStream("world2.txt")){
            try(Writer writer=new OutputStreamWriter(os,"utf-8")){
                try(PrintWriter printWriter=new PrintWriter(writer)){
                    printWriter.println("你好世界");
                    printWriter.print("中国");
                    printWriter.printf("%s %d\r\n","走起来",123);
                    printWriter.flush();//调最底层这个flush就会把数据都刷新一次
                }
            }
        }
    }
}
